home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
DEMON
/
RISCOS2
/
TCP_131S.ARC
/
c
/
ICMPDUMP
< prev
next >
Wrap
Text File
|
1992-08-29
|
2KB
|
78 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "internet.h"
#include "icmp.h"
#include "trace.h"
#include "timer.h"
#include "ip.h"
#include "misc.h"
/* Dump an ICMP header */
void icmp_dump(struct mbuf **bpp, int32 source, int32 dest, int check)
{
struct icmp icmp;
int16 csum;
source = source;
dest = dest;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
csum = cksum(NULLHEADER,*bpp,len_mbuf(*bpp));
ntohicmp(&icmp,bpp);
if(uchar(icmp.type) <= 16 && icmptypes[uchar(icmp.type)] != NULLCHAR)
twprintf("ICMP: %s",icmptypes[uchar(icmp.type)]);
else
twprintf("ICMP: type %u",uchar(icmp.type));
switch(uchar(icmp.type)){
case DEST_UNREACH:
if(uchar(icmp.code) <= 5)
twprintf(" %s",unreach[uchar(icmp.code)]);
else
twprintf(" code %u",uchar(icmp.code));
break;
case REDIRECT:
if(uchar(icmp.code) <= 3)
twprintf(" %s",redirect[uchar(icmp.code)]);
else
twprintf(" code %u",uchar(icmp.code));
break;
case TIME_EXCEED:
if(uchar(icmp.code) <= 1)
twprintf(" %s",exceed[uchar(icmp.code)]);
else
twprintf(" code %u",uchar(icmp.code));
break;
case PARAM_PROB:
twprintf(" pointer = %u",icmp.args.pointer);
break;
case ECHO:
case ECHO_REPLY:
case INFO_RQST:
case INFO_REPLY:
case TIMESTAMP:
case TIME_REPLY:
twprintf(" id %u seq %u",icmp.args.echo.id,icmp.args.echo.seq);
break;
}
if(check && csum != 0){
twprintf(" CHECKSUM ERROR (%u)",csum);
}
twprintf("\n");
/* Dump the offending IP header, if any */
switch(icmp.type){
case DEST_UNREACH:
case TIME_EXCEED:
case PARAM_PROB:
case QUENCH:
case REDIRECT:
twprintf("Returned ");
ip_dump(bpp,0);
}
}